<?php
$server = new \swoole\websocket\server("*.*.*.*", 9501);
$server->set([
    'heartbeat_check_interval' => 15,
]);
$server->on('open', function (\swoole\websocket\server $server, $request) {
    echo "server: handshake success with fd{$request->fd};" . PHP_EOL;
});
$server->on('message', function (\swoole\websocket\server $server, $frame) {
    echo "receive from {$frame->fd}:{$frame->data}" . PHP_EOL;
    $server->push($frame->fd, "this is server-test!");                                                                                  });
$server->on('close', function ($ser, $fd) {
    echo "client {$fd} closed" . PHP_EOL;
});
$server->start();